; iGame v1.6a
; -----------
;
; Date: 2021-11-30
; Author: Henrik Noerfjand Stengaard
;
; User package for HstWB Installer to automate installation of iGame v1.6a.
; iGame v1.6a is patch to not save gamelist each time a whdload is launched,
; which can take 30-60 seconds for a game list with 2000-3000 entries.


; dirs
set igamedir "`execute INSTALLDIR:S/CombinePath "$INSTALLDIR" "iGame"`"
set igameicon "`execute INSTALLDIR:S/CombinePath "$INSTALLDIR" "iGame.info"`"
set muiprefsdir "SYSTEMDIR:Prefs/Env-Archive/mui"

; set igame installed to 1, if igame is installed
set igameinstalled "0"
IF EXISTS "$igamedir"
  set igameinstalled "1"
EndIf

; create igame directory and icons
MakePath >NIL: "$igamedir"
MakeIcon >NIL: "$INSTALLDIR"

; create mui prefs dir, if it doesn't exist
IF NOT EXISTS "$muiprefsdir"
  MakePath >NIL: "$muiprefsdir"
ENDIF

; show igame cpu version request choice
set cpu `RequestChoice "iGame CPU version" "Select iGame CPU version to install*N*NDefault is 68020." "68020|68000|Default"` 

; write install status
echo "iGame..."

; extract igame to temp systemdir
lha -m1 -q x "USERPACKAGEDIR:iGame-1.5.lha" "SYSTEMDIR:Temp/_iGame/"

; install igame files
Copy >NIL: "SYSTEMDIR:Temp/_iGame/iGame.info" "$igameicon" CLONE
Copy >NIL: "SYSTEMDIR:Temp/_iGame/iGame/#?" "$igamedir" CLONE ALL
Copy >NIL: "USERPACKAGEDIR:iGame v1.6a" "$igamedir/iGame" CLONE ALL

; 68020 cpu, default
If Not "$cpu" EQ 2 VAL
  Skip muiprefs
EndIf

; 68000 cpu
Copy >NIL: "USERPACKAGEDIR:iGame.info.000" "$igamedir/iGame.info" CLONE

; mui prefs
LAB muiprefs

; install igame mui prefs, if it doesn't exist
If Not Exists "$muiprefsdir/IGAM.1.prefs"
  Copy >NIL: "USERPACKAGEDIR:IGAM.1.prefs" "$muiprefsdir" CLONE
ENDIF

; delete igame from temp systemdir
Delete >NIL: "SYSTEMDIR:Temp/_iGame" ALL

; backdrop leave out igame
Execute INSTALLDIR:S/Backdrop-LeaveOut "$igamedir/iGame"


; end
; ---
LAB end
